<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <title>用户信息修改</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" type="text/css" href="../ext/ext-all.css" />
		<script type="text/javascript" src="../ext/ext-base.js"></script>
		<script type="text/javascript" src="../ext/ext-all.js"></script>

	<style type="text/css">
	.ext-ie .x-menu-item-icon {left: -24px; top: 0px;}
	.ext-strict .x-menu-item-icon {left: 3px; top: 3px;}
	.ext-ie6 .x-menu-item-icon {left: -24px; top: 0px;}
	</style>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '../images/s.gif';
</script>

	<script type="text/javascript">
	Ext.onReady(function(){
	Ext.QuickTips.init();
	//---定义修改form

	    var simple = new Ext.FormPanel({
	    region: 'east',
        labelWidth: 100, // label settings here cascade unless overridden
        url:'../ajaxjsp/charge.jsp',
        frame:true,
        title: '客户充值',
        bodyStyle:'padding:5px 5px 0',
        width: 300,
        defaults: {width: 230},
        defaultType: 'textfield',
        items:[
            new Ext.form.FieldSet({
            title: '用户信息，不可修改',
            width: 600,
            autoHeight: true,
            defaultType: 'textfield',
	        items: [
{
    fieldLabel: '编号',
    name: 'uids',
    width : '100%',
    xtype:'hidden',
    readOnly:true
},
					{
					    fieldLabel: '用户名',
					    name: 'uuname',
					    width : '100%',
					    readOnly:true
					},{
					    fieldLabel: '密码',
					    name: 'upwd',
					     width : '80%',
					     xtype:'hidden',
					     readOnly:true
					},
					{
					    fieldLabel: '联系方式',
					    width : '100%',
					    name: 'uphone',
					    readOnly:true
					},
					{
					    fieldLabel: '所属代理ID',
					     width : '100%',
					     xtype:'hidden',
					    name: 'ucompany',
					    readOnly:true
					},
					{
					    fieldLabel: '可发短信数',
					     width : '100%',
					    name: 'usmsnum',
					    readOnly:true
					},
					{

					    fieldLabel: '用户等级',
					     width : '100%',
					     xtype:'hidden',
					    name: 'uavailable',
					    readOnly:true
					}
	        	]
	        }),
        new Ext.form.FieldSet({
            title: '短信充值',
            width: 300,
            autoHeight: true,
            defaultType: 'textfield',
            items:[
					{
						 //labelWidth: 160,
					    fieldLabel: '充值短信（条）',
					    name: 'addcharge',
					    width : '100%',
					    xtype:'numberfield'
					}
                   ]})
        ],

        buttons: [{
            text: '充值',
            handler : function(){simple.form.submit({
					waitMsg : '正在处理......',
					success : doSuccess,
					failure : function(form, action) {
						//form.reset();
						if (action.failureType == Ext.form.Action.SERVER_INVALID){
							Ext.MessageBox.alert('错误',action.result.errors.msg);}else{
							Ext.MessageBox.alert('错误','非法输入!!');
							}
					}
				});
            }
        },{
            text: '重填',
            handler : function(){
          		simple.form.reset();
            }
        }]
    });
    //form end

	var UserRecord = Ext.data.Record.create([
        {name: 'uids', type: 'string'},
        {name: 'uuname', type: 'string'},
        {name: 'upwd', type: 'string'},
        {name: 'ucompany', type: 'string'},
        {name: 'usmsnum', type: 'int'},
        {name: 'uregisttime', type: 'string'},
        {name: 'uavailable', type: 'int'}
    ]);


    var store = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({url: '../ajaxjsp/userlist.jsp'}),
        reader: new Ext.data.JsonReader({
        totalProperty: 'totalCount',
        root: 'result'
        },UserRecord),
        remoteSort: true
    });


    var columns = new Ext.grid.ColumnModel([
        //{header: '编号', dataIndex: 'aid',width:1},
        new Ext.grid.RowNumberer(),
        {header: '用户名', dataIndex: 'uuname'},
        {header: '联系方式', dataIndex: 'uphone'},
        {header: '所属代理', dataIndex: 'ucompany'},
        //{header: '用户等级', dataIndex: 'uavailable'},
        {header: '短信余额', dataIndex: 'usmsnum'}
    ]);

    columns.defaultSortable = true;

        var grid = new Ext.grid.GridPanel({
        title: '用户列表',
        region: 'center',
        loadMask: true,
        store: store,
        cm: columns,
        sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
        viewConfig: {
        columnsText:'显示的列',
        sortAscText:'升序',
        sortDescText:'降序',
        forceFit: true
        },
        bbar: new Ext.PagingToolbar({
            pageSize: 15,
            store: store,
            displayInfo: true,
            displayMsg: '显示 {0} 条到 {1} 条记录，一共 {2} 条',
            emptyMsg:'没有记录'

        })
    });

        store.load({params:{start:0,limit:15}});
    grid.on('rowclick',function (grid,rowIndex,event){
    var record = grid.getStore().getAt(rowIndex);
   	simple.getForm().loadRecord(record);
    });


	var viewport = new Ext.Viewport({
	renderTo:'mt',
	layout:'border',
	items:[
	grid,simple,
	{region:'south',contentEl:'inp',heigth:40}
	//{region:'east',html:'east',width:'30%'}
	]
	});

	function doSuccess(form, action){
		Ext.Msg.alert('充值成功',action.result.msg);
		simple.getForm().reset();
		store.reload();
		}

});
	</script>
  </head>

  <body>
   <div id="mt"></div>
   <div id="north1"></div>
    <div id="myf"></div>
   <div id="south"></div>
    <div id="wait" align="center"></div>
   <input id="inp" value="刷新页面" type="button" onclick="javascript:window.location.reload();"></input>
  </body>
</html>
